package com.example.administrator.hqq.adapter.discover;

import android.content.Context;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.resource.bitmap.CenterCrop;
import com.example.administrator.hqq.R;
import com.example.administrator.hqq.utils.transform.GlideCircleTransform;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * @name: HQQ
 * @describe:
 * @author: 康海涛 QQ2541849981
 * @time: 2019/3/19 16:25
 * @remark:
 */
public class GroupMemberPortraitAdapter extends RecyclerView.Adapter<GroupMemberPortraitAdapter.ViewHolder> {
    private List<String> data;
    private int number;
    private Context context;

    public GroupMemberPortraitAdapter(List data, int number, Context context) {
        this.data = data;
        this.number = number;
        this.context = context;
    }

    public class ViewHolder extends RecyclerView.ViewHolder {
        @BindView(R.id.group_member_portrait_image)
        ImageView groupMemberPortraitImage;
        public ViewHolder(View itemView) {
            super(itemView);
            ButterKnife.bind(this, itemView);
        }
    }

    @NonNull
    @Override
    public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View inflate = LayoutInflater.from(context).inflate(R.layout.group_member_portrait_item, null);
        ViewHolder viewHolder = new ViewHolder(inflate);
        return viewHolder;
    }

    @Override
    public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
        if (data!=null&&data.size()>0)
        Glide.with(context).load(data.get(position))
                .transform(new CenterCrop(context),new GlideCircleTransform(context))
                .into(holder.groupMemberPortraitImage);
    }

    @Override
    public int getItemCount() {
        if (data==null)
        {
            return 0;
        }
        return data.size();
    }
}
